/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jpapractica;


import dao.*;
import java.util.List;
import javax.persistence.*;

/**
 *
 * @author master
 */
public class JPAPractica {
    EntityManagerFactory emf;
    EntityManager managerPerson;
    
    public JPAPractica(){
     emf= Persistence.createEntityManagerFactory("GRLUPU");
     managerPerson= emf.createEntityManager();
    }
    
   /* public Person create (int id, String name, String lastname, String picture,
                            String birthplace){
        
        Person persona = new Person(id, name, lastname, picture, birthplace);
        System.out.println("antes de persistir");
        Person p=new Person(10);
        managerPerson.getTransaction().begin();
        managerPerson.persist(persona);
        managerPerson.persist(p);
        managerPerson.getTransaction().commit();
        return persona;*/
        
    
    
    
  //  public static void main(String[] args) {
        // TODO code application logic here
        
        //JPAPractica test =new JPAPractica();
        //System.out.println("creao");
        
        //test.create(100, "andres", "riaño", "hola", "bogota");
        //PersonManager test = new PersonManager();
        //test.update(10, "jose", "luis", "puerto", "bogota", 2012, 12, 12);
       
        
       //test.buscar("jose"); 
       // ActorManager mana= new ActorManager();
        //mana.create(13, "manuel", "deep", "aaaaaa", "washinton", 2014, 05, 05);
       //ArtistManager mana = new ArtistManager();
       //mana.create(8, "fidelino", "pedrozo", "jjjjjj", "cali", 1900, 02, 14);
        
      // DirectorManager mana = new DirectorManager();
      // mana.create(12, "diaz", "hichico", "ooooo", "medellin", 2000, 12, 14);
   // MovieManager mana = new MovieManager();
    //mana.create(6, "avatar", 2000, "iiiii", "dffsdfs", "sdssad", 160, true, true);
    
      /*  ActorManager aaa = new ActorManager(); 
        Actor p = aaa.managerActor.find(Actor.class, 3);
        System.out.println(p.getId()+" zzzzzzzzzzzzzzzzzzzzz"+p.getName());
        List<Movie> peliculas= aaa.buscarpeliculas();//trae todaslapeliculas
        Movie peliculaddelactor= peliculas.get(0);//escoge una pelicula
        List<Actor> actor=aaa.buscar("manuel");//trae una lista con los actores mauel
        Actor aux = actor.get(0);//escoge un actor manuel
        boolean esta=aaa.managerActor.contains(aux);
        System.out.println(aux.getId()+" id del del actor manuel   "+esta+"  "+peliculaddelactor.getName());
        aux.adicionarMovies(peliculaddelactor);
        aaa.managerActor.refresh(aux);
        System.out.println(aux.getLastname()+"    "+aux.movies.get(0).getName());
        
        
        */
        
        
   // }
    
}
